package com.surelution.lansao.wxmp;
/**
 * 
 */


import com.surelution.lansao.Item;
import com.surelution.lansao.Link;
import com.surelution.whistle.core.Attribute;
import com.surelution.whistle.core.BaseAction;

/**
 * @author <a href="mailto:guangzong.syu@gmail.com">Guangzong</a>
 *
 */
public class DefaultAction extends BaseLansaoAction {

	def grailsApplication
	/* (non-Javadoc)
	 * @see com.surelution.whistle.core.BaseAction#accept()
	 */
	@Override
	public boolean accept() {
		return true
	}

	/* (non-Javadoc)
	 * @see com.surelution.whistle.core.BaseAction#execute()
	 */
	@Override
	public void execute() {
		Link link = new Link(member:member, uuid:UUID.randomUUID().toString(), createdAt:new Date())
		link.save(flush:true)
		StringBuilder sb = new StringBuilder("今日供应餐品如下：\n");
		char sn = 'a'
		Item.list().each {item->
			sb.append("""/:eat.<a href="http://${partner.domainName}${com.surelution.lansao.Const.CONTEXT_PATH}/mobileGate/menu?flashId=${link.uuid}&id=${item.id}">${item.name}($item.price)</a>\n""");
			sn++
		}
		sb.append("""请触摸餐品名称订餐。说明：1.查看今日菜单\n2.查询未完成订单\n3.查询过往订单\n4.设置送餐地址\n蓝嫂午餐祝您开心每一天！""")
		put(new Attribute(Attribute.KEY_Content, sb.toString()));
		//
	}

}
